package com.atguigu.practice;

import java.util.Scanner;
import java.util.Stack;

public class ScaleTranslate {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int M=scanner.nextInt(); // 输入的整数
        int N=scanner.nextInt(); //转换的进制数
        StringBuilder sb=new StringBuilder();
        if(N<10){
            Stack<Integer> stack=new Stack<>();
            while(M!=0){
                stack.push(M%N);
                M/=N;
            }
            while(!stack.isEmpty()){
                sb.append(stack.pop());
            }
        }else if(N==10){
            System.out.println(M);
        }else if(N>10){
            Stack<Integer> stack=new Stack<>();
            while(M!=0){
                stack.push(M%N);
                M/=N;
            }
            while(!stack.isEmpty()){
                if(stack.peek()<10){
                    sb.append(stack.pop());
                }else{
                    switch (stack.pop()){
                        case 10:sb.append("A");
                        break;
                        case 11:sb.append("B");
                        break;
                        case 12:sb.append("C");
                        break;
                        case 13:sb.append("D");
                        break;
                        case 14:sb.append("E");
                        break;
                        case 15:sb.append("F");
                        break;
                    }
                }
            }
        }
        System.out.println(sb.toString());
    }
}
